function [gpsposition] = gpsread(serialOpened,maxlength)

if nargin ==1
    maxlength  = 1000;
end
disp('gpsread:starting collect data')
measurementLengthGPS =maxlength;
gpsposition=zeros(measurementLengthGPS,3);
index =0 ;
while(true)
    str1  = fscanf(serialOpened,'%s');
    data    = sscanf(str1,'$GPYBM,SN%d,%f,%f,%f,%f');
    if(isempty(data)==false)
%         disp(data(3:end));
        p=lla2ecef(data(3:end)');
        index = index+1;
        gpsposition(index,:)= p;
        if(index == measurementLengthGPS)
            break;
        end
    end
end